#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int ml[10000000] = { 0 };
int main() 
{
	int l, m, digit, a, b;
	scanf("%d%d", &l, &m);
	digit = l;
	for (; digit >= 0; digit--)
		ml[digit] = 1;
	for (; m > 0; m--) {
		scanf("%d%d", &a, &b);
		for (; b >= a; a++)
			ml[a] = 0;
	}
	digit++;
	for (; l >= 0; l--) {
		if (ml[l] == 1)
			digit++;
	}
	printf("%d", digit);
	return 0;
}//